package com.jnu.hospitalexamination.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jnu.hospitalexamination.common.Result;
import com.jnu.hospitalexamination.entity.Checkitem;
import com.jnu.hospitalexamination.entity.Users;
import com.jnu.hospitalexamination.service.CheckitemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/checkitem")
public class CheckitemController {
    @Autowired
    private CheckitemService checkitemService;
    //返回体检报告项目

    /**
     * 根据订单id返回体检报告项目
     * @param orderId
     * @return
     */
    @RequestMapping("/getCheckitem")
    public Result getCheckitem(@RequestParam("orderId") Integer orderId){
        try {
            return Result.success(200,"success",checkitemService.getCheckitemByOrderId(orderId));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(500,"error"+e.getMessage(),null);
        }
    }

    /**
     * 根据套餐id返回体检报告项目
     * @param smid
     * @return
     */
    @RequestMapping("/getCheckitemBySmid")
    public Result getCheckitemBySmid(@RequestParam("smid") Integer smid){
        try {
            return Result.success(200,"success",checkitemService.getCheckitemBySmid(smid));
        } catch (Exception e){
            e.printStackTrace();
            return Result.error(500,"error"+e.getMessage(),null);
        }
    }
    @RequestMapping("/getCheckitemName")
    public Result getCheckitemName(@RequestParam("ciid") Integer ciid){
        LambdaQueryWrapper<Checkitem> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Checkitem::getCiid, ciid);
        return Result.success(200,"success",checkitemService.getOne(lambdaQueryWrapper).getCiname());
    }
}
